package edu.ccut.saturn.studio.component.page;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormPage;
import org.eclipse.ui.forms.widgets.ScrolledForm;

import edu.ccut.saturn.studio.component.editor.ComponentFileEditor;
import edu.ccut.saturn.studio.component.part.ComponentPagePart;

public class ComponentPage extends FormPage {

	public static final String PART_ID = "view";

	private ComponentFileEditor editor;

	private ComponentPagePart componentPagePart;

	public ComponentPage(ComponentFileEditor editor) {
		super(editor, PART_ID, "View");

		this.editor = editor;
	}

	/**
	 * 创建本页的内容
	 */
	public void createFormContent(IManagedForm parent) {
		ScrolledForm form = parent.getForm();
		GridLayout layout = new GridLayout();
		form.getBody().setLayout(layout);
		
		componentPagePart = new ComponentPagePart(getManagedForm()
				.getForm().getBody(), getManagedForm(), editor);
		
		componentPagePart.getSection().setLayoutData(
				new GridData(SWT.FILL, SWT.FILL, true, true));
		
		getManagedForm().addPart(componentPagePart);
	}
}
